{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "\"\"\"Surface plotting in spherical coordinates\n",
    "\n",
    "spherical harmonic function is: Y(l=2, m=0) = 3*cos(theta)**2 - 1\n",
    "(red points are made NaN on purpose)\n",
    "\"\"\"\n",
    "import numpy as np\n",
    "from vedo import *\n",
    "from vedo.pyplot import plot\n",
    "\n",
    "def rhofunc(theta, phi):\n",
    "    if theta < 0.2:\n",
    "        return np.nan # make some points invalid\n",
    "    #return cos(theta)**2                       # Y(l=1 m=0)\n",
    "    return (3*cos(theta)**2 - 1)**2             # Y(l=2 m=0)\n",
    "    #return (5*cos(theta)**3 - 3*cos(theta))**2 # Y(l=3 m=0)\n",
    "\n",
    "# Build the plot,\n",
    "#  return an Assembly of 3 meshes, the unit\n",
    "#  grid sphere, the surface rho(theta, phi) and\n",
    "#  the red Points where rho is a complex number:\n",
    "spl = plot(rhofunc, mode='spheric', cmap='viridis')\n",
    "\n",
    "show(spl)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
